package com.example.myworkers.controller;

import com.example.myworkers.model.Emp;
import com.example.myworkers.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Objects;

/**
 * @Author: WQX
 * @Description: TODO BaseController相关功能
 * @DateTime: 2023/10/24 19:26
 **/

@RestController
@RequestMapping("base")
public class BaseController {

    @Autowired
    private EmpService empService;

    @GetMapping("login")
    public String login(HttpServletRequest request, Emp emp){
        if (Objects.nonNull(emp)) {
            String msg = empService.login(request,emp);
            return msg;
        }
        return "登录信息不能为空";
    }

    @GetMapping("add")
    public String addEmp(){
        Emp emp = new Emp();
        emp.setId(2);
        emp.setEmpname("xiaoming");
        emp.setSex("1");
        empService.save(emp);
        return "success";
    }
}


